package org.icnmasjid.member.model;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * @hibernate.class table="person_sub_org_role"
 * @author faiz
 *
 */
public class PersonSubOrgRole extends BaseObject {

	private Integer id;
	private Person person;
	private SubOrg subOrg;
	private Role role;

	public PersonSubOrgRole() {
		super();
	}

    /**
     *      *            @hibernate.id
     *             generator-class="native"
     *             type="java.lang.Integer"
     *             column="id"
     *
     */

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }


	/**
	 * @hibernate.many-to-one
	 * 	class="org.icnmasjid.member.model.Role"
	 * 	column="role_id"
	 */
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	/**
	 * @hibernate.many-to-one
	 * 	class="org.icnmasjid.member.model.SubOrg"
	 * 	column="sub_org_id"
	 */
	public SubOrg getSubOrg() {
		return subOrg;
	}

	public void setSubOrg(SubOrg subOrg) {
		this.subOrg = subOrg;
	}

	/**
	 * @hibernate.many-to-one
	 * 	class="org.icnmasjid.member.model.Person"
	 * 	column="person_id"
	 */
	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	@Override
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((id == null) ? 0 : id.hashCode());
		result = PRIME * result + ((person == null) ? 0 : person.hashCode());
		result = PRIME * result + ((role == null) ? 0 : role.hashCode());
		result = PRIME * result + ((subOrg == null) ? 0 : subOrg.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final PersonSubOrgRole other = (PersonSubOrgRole) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (person == null) {
			if (other.person != null)
				return false;
		} else if (!person.equals(other.person))
			return false;
		if (role == null) {
			if (other.role != null)
				return false;
		} else if (!role.equals(other.role))
			return false;
		if (subOrg == null) {
			if (other.subOrg != null)
				return false;
		} else if (!subOrg.equals(other.subOrg))
			return false;
		return true;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("id", this.id).append("role", this.role).append(
						"person", this.person).append("subOrg", this.subOrg)
				.toString();
	}

}